package com.vidmt.api.common.utils;

import java.util.Map;

import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.persistence.DataEntity;

public class IDUtil {
	private static Map<Class<? extends DataEntity>, IDUtil> map = Maps.newHashMap();

	public static IDUtil get(Class<? extends DataEntity> clz) {
		IDUtil idutil = map.get(clz);
		if (idutil == null) {
			idutil = new IDUtil();
			map.put(clz, idutil);
		}
		return idutil;
	}

	private long id = -10;

	private IDUtil() {
	}

	public synchronized void reset(long id) {
		this.id = id;
	}

	public synchronized long current() {
		return id;
	}

	public synchronized void increment() {
		id++;
	}
	public synchronized void decrement() {
		id--;
	}
}
